/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Member;

import Entity.DatabaseConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Elisa
 */
public class ControllerMemberBaru {
      public static String IDMember() {
        String IDMember = "";
        try {
            String sql = "select IDMEMBER from MEMBER order by IDMEMBER desc";
            Connection conn = DatabaseConnection.getConnection();

            PreparedStatement ps = conn.prepareStatement(sql);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                IDMember = (Integer.parseInt(rs.getString(1).substring(3)) + 1) + "";
                while (IDMember.length() < 3) {
                    IDMember = "0" + IDMember;
                }
                IDMember = "mm-" + IDMember;
            } else {
                IDMember = "mm-0001";
            }

        } catch (SQLException ex) {
            Logger.getLogger(ControllerMemberBaru.class.getName()).log(Level.SEVERE, null, ex);
        }
        return IDMember;
    }
}
